<template>
    <div>
        <el-tabs tab-position="left" style="height: 500px;" type="border-card" v-model="activeName">

<!--    基本信息        -->
            <el-tab-pane label="基本信息">
                    <el-row :gutter="20" class="row" type="flex" justify="space-around" align="bottom">
                        <el-col :span="10">
                        <div class="grid-content bg-purple">
                            <span class="sender">用户名：{{user.username}}</span>
                        </div>
                        </el-col>
                        <el-col :span="10">
                            <div class="grid-content bg-purple">
                                <span class="sender">头像：
                                <el-image
                                        style="width: 100px; height: 100px"
                                        :src="user.avatar"
                                >
                                </el-image>
                                </span>
                            </div>
                        </el-col>
                    </el-row>
                    <el-row class="row" type="flex" justify="space-around" align="bottom">
                        <el-col :span="10">
                            <div class="grid-content bg-purple">
                                <span class="sender">邮箱：{{user.email}}</span>
                            </div>
                        </el-col>
                        <el-col :span="10">
                            <div class="grid-content bg-purple">

                            </div>
                        </el-col>
                    </el-row>
                    <el-row class="row" type="flex" justify="space-around" align="bottom">
                        <el-col :span="10">
                            <div class="grid-content bg-purple">
                                <span class="sender">用户类型:
                                    <span v-if="user.type==1">患者</span>
                                    <span v-if="user.type==2">医生</span>
                                    <span v-if="user.type==4">医学生</span>
                                </span>
                            </div>
                        </el-col>
                        <el-col :span="10">
                            <div class="grid-content bg-purple">

                            </div>
                        </el-col>
                    </el-row>
                    <el-row class="row" type="flex" justify="space-around" align="bottom">
                    <el-col :span="10">
                        <div class="grid-content bg-purple">
                            <span class="sender">个人id:{{user.uuid}}</span>
                        </div>
                    </el-col>
                    <el-col :span="10">
                        <div class="grid-content bg-purple">

                        </div>
                    </el-col>
                 </el-row>
                <el-row class="row" type="flex" justify="space-around" align="bottom">
                    <el-col :span="10">
                        <div class="grid-content bg-purple">
                            <span class="sender">发布帖子数:{{user.postnumber}}</span>
                        </div>
                    </el-col>
                    <el-col :span="10">
                        <div class="grid-content bg-purple">

                        </div>
                    </el-col>
                </el-row>
                <el-row class="row" type="flex" justify="space-around" align="bottom">
                    <el-col :span="9">
                        <div class="grid-content bg-purple">
                            <el-button ttype="primary" round @click="dialogFormVisible = true">修改个人信息</el-button>
                        </div>
                    </el-col>
                    <el-dialog title="信息修改" :visible.sync="dialogFormVisible">
                        <el-form  :model="ruleForm" :rules="rules" ref="ruleForm">
                            <el-form-item  label="用户名" prop="username" label-width="100px">
                                <el-input v-model="ruleForm.username"></el-input>
                            </el-form-item>
                            <el-form-item label="新密码" prop="password" label-width="100px">
                                <el-input type="password" v-model="ruleForm.password" autocomplete="off"></el-input>
                            </el-form-item>
                            <el-form-item label="确认密码" prop="checkPass" label-width="100px">
                                <el-input type="password" v-model="ruleForm.checkPass" autocomplete="off"></el-input>
                            </el-form-item>
                            <el-form-item label="邮箱" prop="email" label-width="100px">
                                <el-input v-model="ruleForm.email"></el-input>
                            </el-form-item>
                            <el-form-item>
                            <el-button @click="dialogFormVisible = false">取 消</el-button>
                            <el-button type="primary" style="margin-top: 12px;"
                                       @click="submitForm('ruleForm')">修改</el-button>
                            </el-form-item>
                        </el-form>



                    </el-dialog>
                </el-row>




            </el-tab-pane>
<!--    头像上传        -->
            <el-tab-pane label="头像上传">
                <h1>上传你的个人头像</h1>
                    <el-upload
                            class="avatar-uploader"
                            :action=url
                            :show-file-list="false"
                            :on-success="handleAvatarSuccess"
                            :before-upload="beforeAvatarUpload">
                        <img v-if="imageUrl" :src="imageUrl" class="avatar">
                        <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                    </el-upload>

            </el-tab-pane>
<!--    详情信息        -->
            <el-tab-pane label="详情信息" >
<!--      患者          -->
                <div v-if="user.type==1">
                <el-row :gutter="20" class="row" type="flex" justify="space-around" align="bottom">
                    <el-col :span="10">
                        <div class="grid-content bg-purple">
                            <span class="sender">姓名：{{patient.name}}</span>
                        </div>
                    </el-col>
                    <el-col :span="10">
                        <div class="grid-content bg-purple">
                                <span class="sender">年龄：
                                {{patient.age}}岁
                                </span>
                        </div>
                    </el-col>
                </el-row>
                <el-row class="row" type="flex" justify="space-around" align="bottom">
                    <el-col :span="10">
                        <div class="grid-content bg-purple">
                            <span class="sender">身高：{{patient.height}}厘米</span>
                        </div>
                    </el-col>
                    <el-col :span="10">
                        <div class="grid-content bg-purple">
                            <div class="grid-content bg-purple">
                                <span class="sender">糖尿病病型:{{patient.diabetictype}}</span>
                            </div>
                        </div>
                    </el-col>
                </el-row>
                <el-row class="row" type="flex" justify="space-around" align="bottom">
                    <el-col :span="10">
                        <div class="grid-content bg-purple">
                                <span class="sender">体重:{{patient.weight}}公斤
                                </span>
                        </div>
                    </el-col>
                    <el-col :span="10">
                        <div class="grid-content bg-purple">
                            <span class="sender">症状:
                                <el-select v-model="ruleForm1.symptom" placeholder="请选择症状" multiple
                                           clearable :style="{ width: '270px' }" disabled>
                                        <el-option v-for="dict in symptomOptions"
                                                   :key="dict.id"
                                                   :label="dict.symptom"
                                                   :value="dict.symptom"></el-option>

                                    </el-select>
                            </span>
                        </div>
                    </el-col>
                </el-row>
                <el-row class="row" type="flex" justify="space-around" align="bottom">
                    <el-col :span="10">
                        <div class="grid-content bg-purple">
                            <span class="sender">既往病史:{{patient.pasthistory}}</span>
                        </div>
                    </el-col>
                    <el-col :span="10">
                        <div class="grid-content bg-purple">

                        </div>
                    </el-col>
                </el-row>
                    <el-row class="row" type="flex" justify="space-around" align="bottom">
                        <el-col :span="9">
                            <div class="grid-content bg-purple">
                                <el-button ttype="primary" round @click="dialogFormVisible = true">修改个人信息</el-button>
                            </div>
                        </el-col>
                        <el-dialog title="详情信息修改" :visible.sync="dialogFormVisible">
                            <el-form :model="ruleForm1" :rules="rules" ref="ruleForm1" label-width="100px" class="demo-ruleForm">
                                <el-form-item  label="姓名" prop="name">
                                    <el-input v-model="ruleForm1.name"></el-input>
                                </el-form-item>
                                <el-form-item label="年龄" prop="age">
                                    <el-input  v-model.number="ruleForm1.age" autocomplete="off"></el-input>
                                </el-form-item>
                                <el-form-item label="身高(厘米)" prop="height">
                                    <el-input  v-model.number="ruleForm1.height" autocomplete="off"></el-input>
                                </el-form-item>
                                <el-form-item label="体重（公斤）" prop="weight">
                                    <el-input  v-model.number="ruleForm1.weight" autocomplete="off"></el-input>
                                </el-form-item>

                                <el-form-item label="糖尿病类型" prop="diabetictype">
                                    <el-select v-model="ruleForm1.diabetictype" placeholder="请选择糖尿病类型">
                                        <el-option v-for="dict in czyOptions"
                                                   :key="dict.id"
                                                   :label="dict.diabetesname"
                                                   :value="dict.diabetesname"></el-option>

                                    </el-select>
                                </el-form-item>
                                <el-form-item label="症状" prop="symptom">
                                    <el-select v-model="ruleForm1.symptom" placeholder="请选择症状" multiple
                                               clearable :style="{ width: '270px' }">
                                        <el-option v-for="dict in symptomOptions"
                                                   :key="dict.id"
                                                   :label="dict.symptom"
                                                   :value="dict.symptom"></el-option>

                                    </el-select>
                                </el-form-item>
                                <el-form-item label="过往病史">
                                    <el-input type="textarea" v-model="ruleForm1.pasthistory"></el-input>
                                </el-form-item>
                                <el-form-item>
                                    <el-button @click="dialogFormVisible = false">取 消</el-button>
                                    <el-button style="margin-top: 12px;" type="primary"
                                               @click="submitForm1('ruleForm1')">修改</el-button>

                                </el-form-item>
                            </el-form>



                        </el-dialog>
                    </el-row>
                </div>
<!--      医生         -->
                <div v-if="user.type!=1">
                    <el-row :gutter="20" class="row" type="flex" justify="space-around" align="bottom">
                        <el-col :span="10">
                            <div class="grid-content bg-purple">
                                <span class="sender">姓名：{{doctor.name}}</span>
                            </div>
                        </el-col>
                        <el-col :span="10">
                            <div class="grid-content bg-purple">
                                <span class="sender">年龄：{{doctor.age}}
                                </span>
                            </div>
                        </el-col>
                    </el-row>
                    <el-row class="row" type="flex" justify="space-around" align="bottom">
                        <el-col :span="10">
                            <div class="grid-content bg-purple">
                                <span class="sender">就职医院：{{doctor.hospital}}</span>
                            </div>
                        </el-col>
                        <el-col :span="10">
                            <div class="grid-content bg-purple">
                                <span class="sender">毕业院校：{{doctor.graduate}}</span>
                            </div>
                        </el-col>
                    </el-row>
                    <el-row class="row" type="flex" justify="space-around" align="bottom">
                        <el-col :span="10">
                            <div class="grid-content bg-purple">
                                <span class="sender">专业：{{doctor.education}}
                                </span>
                            </div>
                        </el-col>
                        <el-col :span="10">
                            <div class="grid-content bg-purple">
                                <span class="sender">医龄：{{doctor.years}}</span>
                            </div>
                        </el-col>
                    </el-row>
                    <el-row class="row" type="flex" justify="space-around" align="bottom">
                        <el-col :span="10">
                            <div class="grid-content bg-purple">
                                <span class="sender">自我介绍：{{doctor.self}}</span>
                            </div>
                        </el-col>
                        <el-col :span="10">
                            <div class="grid-content bg-purple">

                            </div>
                        </el-col>
                    </el-row>
                    <el-row class="row" type="flex" justify="space-around" align="bottom">
                        <el-col :span="9">
                            <div class="grid-content bg-purple">
                                <el-button ttype="primary" round @click="dialogFormVisible = true">修改个人信息</el-button>
                            </div>
                        </el-col>
                        <el-dialog title="信息修改" :visible.sync="dialogFormVisible">
                            <el-form :model="ruleForm2" :rules="rules" ref="ruleForm2" label-width="100px" class="demo-ruleForm">
                                <el-form-item  label="uuid" prop="userid" style="display: none">
                                    <el-input v-model="ruleForm2.userid"></el-input>
                                </el-form-item>
                                <el-form-item  label="姓名" prop="name">
                                    <el-input v-model="ruleForm2.name"></el-input>
                                </el-form-item>
                                <el-form-item label="年龄" prop="age">
                                    <el-input  v-model.number="ruleForm2.age" autocomplete="off"></el-input>
                                </el-form-item>
                                <el-form-item label="毕业院校" prop="graduate">
                                    <el-input  v-model="ruleForm2.graduate" autocomplete="off"></el-input>
                                </el-form-item>
                                <el-form-item label="就职医院" prop="hospital">
                                    <el-input  v-model="ruleForm2.hospital" autocomplete="off"></el-input>
                                </el-form-item>
                                <el-form-item label="专业" prop="education">
                                    <el-input  v-model="ruleForm2.education" autocomplete="off"></el-input>
                                </el-form-item>
                                <el-form-item label="医龄" prop="years">
                                    <el-input  v-model.number="ruleForm2.years" autocomplete="off"></el-input>
                                </el-form-item>
                                <el-form-item label="自我介绍">
                                    <el-input type="textarea" v-model="ruleForm2.self"></el-input>
                                </el-form-item>
                                <el-form-item>
                                    <el-button @click="dialogFormVisible = false">取 消</el-button>
                                    <el-button style="margin-top: 12px;" type="primary"
                                                   @click="submitForm2('ruleForm2')">修改</el-button>

                                </el-form-item>

                            </el-form>



                        </el-dialog>
                    </el-row>

                </div>
            </el-tab-pane>
            <el-tab-pane label="我的咨询" :disabled="showQ" name="question">
                <el-card class="box-card" v-for="que in question">
                    <div   class="text item">
                        {{que.content}}
                    </div>
                    <el-button type="text" style="color: #66ccff!important;font-weight: 700!important;"
                               @click="getQdetail(que)">详情</el-button>
                    <el-button type="text" style="color: #ff0066!important;font-weight: 700!important;"
                               @click="deleteQ(que)">删除</el-button>
                </el-card>
            </el-tab-pane>

            <el-tab-pane label="我的解疑" :disabled="showA" name="answer">
                <el-card class="box-card" v-for="dict in answer">
                    <div   class="text item">
                            {{dict.content}}
                    </div>
                    <el-button type="text" style="color: #66ccff!important;font-weight: 700!important;"
                               @click="getAdetail(dict)">详情</el-button>
                    <el-button type="text" style="color: #ff0066!important;font-weight: 700!important;"
                    <el-button type="text" style="color: #ff0066!important;font-weight: 700!important;"
                               @click="deleteA(dict)">删除</el-button>
                </el-card>

            </el-tab-pane>

            <el-tab-pane label="我的帖子" name="post">
                <el-card class="box-card" v-for="dict in posts">
                    <div   class="text item">
                        {{dict.title}}
                    </div>
                    <el-button type="text" style="color: #66ccff!important;font-weight: 700!important;"
                               @click="postdetail(dict)">详情</el-button>
                    <el-button type="text" style="color: #ff0066!important;font-weight: 700!important;"
                               @click="deletePost(dict)">删除</el-button>
                </el-card>

            </el-tab-pane>

            <el-tab-pane label="我的评论" name="comment">

                <el-card class="box-card" v-for="dict in comments">
                    <div   class="text item">
                        {{dict.content}}
                    </div>
                    <el-button type="text" style="color: #66ccff!important;font-weight: 700!important;"
                               @click="postdetail2(dict)">详情</el-button>
                    <el-button type="text" style="color: #ff0066!important;font-weight: 700!important;"
                               @click="deletePost(dict)">删除</el-button>
                </el-card>

            </el-tab-pane>
        </el-tabs>
        <!--<el-drawer
                title="我是标题"
                :visible.sync="drawer"
                :direction="direction"
                :before-close="handleClose">
            <span>我来啦!</span>
        </el-drawer>-->
    </div>
</template>
<script>
    export default {

        data() {
            var checkAge = (rule, value, callback) => {
                if (!value) {
                    return callback(new Error('年龄不能为空'));
                }
                setTimeout(() => {
                    if (!Number.isInteger(value)) {
                        callback(new Error('请输入数字值'));
                    } else {
                        if (value > 100) {
                            callback(new Error('请输入正常年龄'));
                        } else {
                            callback();
                        }
                    }
                }, 1000);
            };
            var checkWeight = (rule, value, callback) => {
                if (!value) {
                    return callback(new Error('体重不能为空'));
                }
                setTimeout(() => {
                    if (!Number.isInteger(value)) {
                        callback(new Error('请输入数字值'));
                    } else {
                        if (value > 300||value<1) {
                            callback(new Error('请输入正常体重'));
                        } else {
                            callback();
                        }
                    }
                }, 1000);
            };
            var checkHeight = (rule, value, callback) => {
                if (!value) {
                    return callback(new Error('身高不能为空'));
                }
                setTimeout(() => {
                    if (!Number.isInteger(value)) {
                        callback(new Error('请输入数字值'));
                    } else {
                        if (value > 250||value<76) {
                            callback(new Error('请输入正常身高'));
                        } else {
                            callback();
                        }
                    }
                }, 1000);
            };
            var checkYears = (rule, value, callback) => {
                if (!value) {
                    return callback(new Error('医龄不能为空'));
                }
                setTimeout(() => {
                    if (!Number.isInteger(value)) {
                        callback(new Error('请输入数字值'));
                    } else {
                        if (value > 70) {
                            callback(new Error('请输入正常医龄'));
                        } else {
                            callback();
                        }
                    }
                }, 1000);
            };
            var validatePass = (rule, value, callback) => {
                if (value === '') {
                    callback(new Error('请输入密码'));
                } else {
                    if (this.ruleForm.checkPass !== '') {
                        this.$refs.ruleForm.validateField('checkPass');
                    }
                    callback();
                }
            };
            var validatePass2 = (rule, value, callback) => {
                if (value === '') {
                    callback(new Error('请再次输入密码'));
                } else if (value !== this.ruleForm.password) {
                    callback(new Error('两次输入密码不一致!'));
                } else {
                    callback();
                }
            };
            return {
                activeName:'',
                drawer: false,
                direction: 'ttb',
                showA:false,
                showQ:false,
                dialogFormVisible: false,
                imageUrl: '',
                czyOptions: [],
                url: '',
                user:{
                    username:'',
                    email:'',
                    avatar:'https://www.gdpu.edu.cn/images/xh.png',
                    postnumber:'',
                    uuid:'',
                    type:''
                },
                ruleForm: {
                    username:'',
                    password: '',
                    checkPass: '',
                    email: '',

                },
                patient: {
                    name: '',
                    age: '',
                    weight:'',
                    height:'',
                    diabetictype:[],
                    symptom:[],
                    pasthistory:'',
                },
                ruleForm1: {
                    name: '',
                    age: '',
                    weight:'',
                    height:'',
                    diabetictype:[],
                    symptom:[],
                    pasthistory:'',
                },
                doctor: {
                    name: '',
                    age: '',
                    hospital:'',
                    graduate:'',
                    education:'',
                    years:'',
                    self:'',
                },
                ruleForm2: {
                    name: '',
                    age: '',
                    hospital:'',
                    graduate:'',
                    education:'',
                    years:'',
                    self:'',
                },
                answer:[
                    {
                    id:'',
                    content:'',
                    questionid:''
                },
                    {
                        id:'',
                        content:'',
                        questionid:''
                    },
                ],
                posts:[
                    {
                        id:'',
                        title:'',
                    },
                    {
                        id:'',
                        content:'',
                    },
                ],
                comments:[
                    {
                        postid:'',
                        content:'',
                    },
                ],
                atoq:{
                    content:'',
                    answer:''
                },
                question:[
                    {
                        id:'',
                        content:''
                    },
                    {
                        id:'',
                        content:''
                    },
                ],
                formLabelWidth: '120px',
                rules: {
                    username: [
                        { required: true, message: '请输入用户名', trigger: 'blur' },
                        { min: 3, max: 8, message: '长度在 3 到 8 个字符', trigger: 'blur' }
                    ],
                    type: [
                        { required: true, message: '请选择用户类型', trigger: 'change' },

                    ],
                    password: [
                        { validator: validatePass, trigger: 'blur' },
                        { max: 8, message: '长度在 3 到 8 个字符', trigger: 'blur' }
                    ],
                    checkPass: [
                        { validator: validatePass2, trigger: 'blur' }
                    ],
                    email: [
                        { required: true, message: '请输入邮箱地址', trigger: 'blur' },
                        { type: 'email', message: '请输入正确的邮箱地址', trigger: ['blur', 'change'] }
                    ],
                    name: [
                        { required: true, message: '请输入姓名', trigger: 'blur' },
                        { min: 2, max: 4, message: '长度在 2 到 4 个字符', trigger: 'blur' }
                    ],
                    age: [
                        { validator: checkAge, trigger: 'blur' }
                    ],
                    weight: [
                        { validator: checkWeight, trigger: 'blur' }
                    ],
                    height: [
                        { validator: checkHeight, trigger: 'blur' }
                    ],
                    years: [
                        { validator: checkYears, trigger: 'blur' }
                    ],

                }
            };
        },
        methods: {
            submitForm(formName) {
                console.log(formName);
                const _this = this
                this.$refs[formName].validate((valid) => {
                    if (valid) {
                        axios.put("http://localhost:8181/user/edit", this.ruleForm).then(function (resp) {
                            if (resp.data.msg == 'success') {
                                _this.$message("修改成功");
                                _this.dialogFormVisible= false
                            } else {
                                _this.$message("你的用户名已被注册");
                            }

                        });

                    } else {

                        return false;
                    }
                });
            },
            submitForm1(formName) {
                const _this = this
                this.$refs[formName].validate((valid) => {
                    if (valid) {
                        axios.put("http://localhost:8181/patient/edit",this.ruleForm1).then(function (resp) {
                            if (resp.data.msg === 'success'){
                                _this.$message("修改成功！");
                                window.location.reload();
                            }else {
                                _this.$message("还有资料错误！");
                            }

                        });

                    } else {

                        return false;
                    }
                });
            },
            submitForm2(formName) {
                const _this = this
                this.$refs[formName].validate((valid) => {
                    if (valid) {
                        axios.put("http://localhost:8181/doctor/edit",this.ruleForm2).then(function (resp) {
                            if (resp.data.msg === 'success'){
                                _this.$message("修改成功！");
                                window.location.reload();
                            }else {
                                _this.$message("还有资料错误！");
                            }

                        });

                    } else {

                        return false;
                    }
                });
            },
            handleAvatarSuccess(res, file) {
                this.imageUrl = URL.createObjectURL(file.raw);

                    this.$message({
                        message: '上传成功！重新登录即可刷新！',
                        type: 'success'
                    });

            },
            beforeAvatarUpload(file) {
                const isJPG = file.type === 'image/jpeg';
                const isLt2M = file.size / 1024 / 1024 < 2;

                if (!isJPG) {
                    this.$message.error('上传头像图片只能是 JPG 格式!');
                }
                if (!isLt2M) {
                    this.$message.error('上传头像图片大小不能超过 2MB!');
                }
                return isJPG && isLt2M;
            },
            deleteA(dict) {
                const _this = this;
                axios.delete("http://localhost:8181/consult/deleteA/"+dict.id).then(function (resp) {
                    if (resp.data.data == 'success'){
                        _this.$message({
                            message: '删除成功！',
                            type: 'success'
                        });
                        window.location.reload();
                    }
                })
            },
            deleteQ(dict) {
                const _this = this;
                axios.delete("http://localhost:8181/consult/deleteQ/"+dict.id).then(function (resp) {
                    if (resp.data.data == 'success'){
                        _this.$message({
                            message: '删除成功！',
                            type: 'success'
                        });
                        window.location.reload();
                    }
                })
            },
            deletePost(dict) {
                const _this = this;
                axios.delete("http://localhost:8181/forum/deletePost/"+dict.id).then(function (resp) {
                    if (resp.data.data == 'success'){
                        _this.$message({
                            message: '删除成功！',
                            type: 'success'
                        });
                        window.location.reload();
                    }
                })
                axios.post("http://localhost:8181/forum/postDown/"+this.user.uuid).then(function (resp) {
                    /*if (resp.data.data == 'success'){
                        _this.$message({
                            message: '删除成功！',
                            type: 'success'
                        });
                        window.location.reload();
                    }*/
                })
            },
            getQdetail(que){
                console.log(que.id)
                this.$router.push({
                    path: '/questiondetail',
                    query: {
                        id: que.id
                    }
                })
            },
            getAdetail(dict){
                console.log(dict.questionid)
                this.$router.push({
                    path: '/questiondetail',
                    query: {
                        id: dict.questionid
                    }
                })
            },
            postdetail(dict){
                console.log(dict.id)
                this.$router.push({
                    path: '/showPost',
                    query: {
                        id: dict.id,
                        userid:dict.userid
                    }
                })
            },
            postdetail2(dict){
                console.log(dict.postid)
                this.$router.push({
                    path: '/showPost',
                    query: {
                        id: dict.postid,
                        userid:dict.userid
                    }
                })
            },
        },
        created() {
            if(this.$store.getters.getUser.id) {
                this.user.uuid = this.$store.getters.getUser.id;
                this.user.username = this.$store.getters.getUser.username;
                this.user.type = this.$store.getters.getUser.type;
                this.user.avatar = this.$store.getters.getUser.avatar;
                this.url = "http://localhost:8181/upload/"+this.user.uuid

            }
            const _this = this;
            _this.activeName = this.$route.query.activeName
            axios.get("http://localhost:8181/user/findbyid/"+this.user.uuid).then(function (resp) {
                _this.user= resp.data.data
                _this.ruleForm= resp.data.data
            });
            if(this.$store.getters.getUser.type!=1){
                _this.showQ = true
                _this.showA = false
            }
            if(this.$store.getters.getUser.type==1){
                _this.showQ = false
                _this.showA = true
            }

            axios.get("http://localhost:8181/consult/findAbyuid/"+this.user.uuid).then(function (resp) {
                _this.answer = resp.data.data;
            });
            axios.get("http://localhost:8181/consult/findQbyuid/"+this.user.uuid,).then(function (resp) {
                _this.question = resp.data.data;
            });

            axios.get("http://localhost:8181/forum/findPostbyuid/"+this.user.uuid).then(function (resp) {
                _this.posts = resp.data.data;
            });

            axios.get("http://localhost:8181/comment/findcommentbyuserUuid/"+this.user.uuid
            ).then(function (resp){
                _this.comments = resp.data.data;
                console.log(_this.comments)
            });
            axios.get("http://localhost:8181/listdiaType").then(function (resp) {
                _this.czyOptions = resp.data.data;
            });
            axios.get("http://localhost:8181/listSymptom").then(function (resp) {
                _this.symptomOptions = resp.data.data;
            });
            if (this.user.type==1){
                axios.get("http://localhost:8181/patient/findbyid/"+this.user.uuid).then(function (resp) {
                    _this.patient= resp.data.data
                    _this.ruleForm1= resp.data.data

                });
            }else {
                axios.get("http://localhost:8181/doctor/findbyid/"+this.user.uuid).then(function (resp) {
                    _this.doctor= resp.data.data
                    _this.ruleForm2= resp.data.data
                });
            }
        },


    }
</script>

<style scoped>
    .row {
        margin-top: 40px !important;
        text-align: center !important;
    }
    el-col {
        text-align: center !important;
    }
    .avatar-uploader .el-upload {
        border: 1px dashed #d9d9d9;
        border-radius: 6px;
        cursor: pointer;
        position: relative;
        overflow: hidden;
    }
    .avatar-uploader .el-upload:hover {
        border-color: #409EFF;
    }
    .avatar-uploader-icon {
        font-size: 28px;
        color: #8c939d;
        width: 178px;
        height: 178px;
        line-height: 178px;
        text-align: center;
    }
    .avatar {
        width: 178px;
        height: 178px;
        display: block;
    }
    .text {
        font-size: 14px;
    }

    .item {
        padding: 5px 0;
    }

    .box-card {
        margin-left: 100px;
        width: 700px;
    }
</style>